package com.jiangli.controller.admin;



import com.jiangli.dto.UserPageQueryDTO;
import com.jiangli.entity.User;
import com.jiangli.result.PageResult;
import com.jiangli.result.Result;
import com.jiangli.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminUserController")
@RequestMapping("/admin/user")
@Api(tags="管理端用户接口")
@Slf4j
public class UserController {


    @Autowired
    private UserService userService;
    @GetMapping("/page")
    @ApiOperation("分页查询用户")
    public Result<PageResult> showAllUser(UserPageQueryDTO userPageQueryDTo) {
        PageResult pageResult=userService.pageQuery(userPageQueryDTo);
        return Result.success(pageResult);
    }

    /**
     * 启用禁用员工账号
     * 通过路劲传参
     * @param status
     * @param id
     * @return
     */
    @PostMapping("/status/{status}")
    @ApiOperation("修改用户账号状态")
    public Result startOrStop(@PathVariable Integer status, Long id) {
        log.info("修改用户状态：{}{}",status,id);
        userService.updateUserStatus(status,id);
        return Result.success();
    }

}
